﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Frogism.Domain {
  public class WorkoutManager {

    public IEnumerable<Core.WorkOut.IActivityType> GetActivityList() {
      var loader = new Data.ActivityTypeLoader();
      return loader.GetAll();
    }

    public Core.WorkOut.IActivity GetActivity(int id) {
      var loader = new Data.ActivityLoader();
      return loader.GetById(id);
    }

    public IEnumerable<Core.WorkOut.ActivityStatus> GetStatusList() {
      //return Core.WorkOut.ActivityStatus.GetAll();
        
        List<Core.WorkOut.ActivityStatus> list = new List<Core.WorkOut.ActivityStatus>();

        int cnt;
        cnt = Enum.GetValues(typeof(Core.WorkOut.ActivityStatus)).GetLength(0);
        for(int i = 1;i<= cnt;i++){
            list.Add((Core.WorkOut.ActivityStatus)i);
        }
        return list;
    }

    public void Delete(int id) {
      var loader = new Data.ActivityLoader();
      loader.Delete(id);
    }
    public void Create(Core.WorkOut.Activity activity) {
      var loader = new Data.ActivityLoader();
      loader.Create(activity);
    }
    public void Update(Core.WorkOut.Activity activity) {
      var loader = new Data.ActivityLoader();
      loader.Save(activity);
    }

    public Frogism.Core.WorkOut.IActivity DefaultActivity() {
      var a = new Core.WorkOut.Activity();
      a.Id = -1;
      a.Name = string.Empty;
      a.ActivityDate = DateTime.Now;
      a.Status = Core.WorkOut.ActivityStatus.Predicted;
      a.ActivityType = GetActivityList().First();
      return a;
    }
  }
}
